#!/bin/bash

#initial
if [ -d ~/linlabs ]
then
  echo "was created before"
else
  mkdir ~/linlabs
  touch ~/linlabs/work2.log
fi


# 1 ------------------------------
[ -d ~/linlabs/test ] && {
  echo "File exists"
} || {
  mkdir ~/linlabs/test && echo "1. Directory 'test' was created successfully" >> ~/linlabs/work2.log
}
sleep 1s

# 2 ------------------------------
#tty2 => tail -f work2.log

# 3 ------------------------------
touch ~/linlabs/test/calendar.txt; echo "2. I/O Streams usage example" >> ~/linlabs/work2.log
cal -y | tee --append ~/linlabs/test/calendar.txt ~/linlabs/work2.log

# 4 ------------------------------
echo "3. Current system usage statistics" >> ~/linlabs/work2.log
sh lab2-1-sub.sh >> ~/linlabs/work2.log

# 5 ------------------------------
ping google.ifmo.ru 2> /dev/null && echo "What the hell?" || {
  echo "Nope, google's not here";
  mkdir ~/linlabs/test/log 2> /dev/null
  echo "Host is not available" > ~/linlabs/test/log/nettest.log
}

